package com.cj.netlibrary.retrofit

import com.cj.commonlibrary.BaseUrl
import com.cj.netlibrary.okhttp.OkHttpManager
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory

/**
 *created by chen jun
 *on 2021/5/24 18:12
 */
object RetrofitWithRxjava2Manager {
    private val retrofit:Retrofit by lazy {
        Retrofit.Builder()
            .client(OkHttpManager.okHttpClient)
            .baseUrl(BaseUrl.BASE_URL)
            .addConverterFactory(GsonConverterFactory.create())
            .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
            .build()
    }
    fun<T> createApiService(c:Class<T>):T{
        return retrofit.create(c)
    }
}